/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.panomedic.colors;

/**
 *
 * @author Yare
 */
public class ColorConstants {

    public static final int NUM_COMP = 3;
    
    public static final int NUM_CS = 6;
    public static final int RGB = 0;
    public static final int HSV = 1;
    public static final int Yxy = 2;
    public static final int Lab = 3;
    public static final int LCh = 4;
    public static final int Luv = 5;
    
    public static final String SPACE_NAME[] = {
		"RGB",
		"HSV",
		"CIE Yxy",
		"CIE Lab",
                "CIE LCh",
                "CIE Luv"
    };
    
    /**
     * values of pixel data containing luminosity component of color
     * @param type
     * @return
     */
    public static boolean[] getLumComp(int type){
        boolean[] lum;
        switch (type){
            case(RGB):  lum = new boolean[]{ true, true, true};
                        break;
            case(HSV):  lum = new boolean[]{ false, false, true};
                        break;
            case(Yxy):  lum = new boolean[]{ true, false, false};
                        break;
            case(Lab):  lum = new boolean[]{ true, false, false};
                        break;
            case(LCh):  lum = new boolean[]{ true, false, false};
                        break;
            case(Luv):  lum = new boolean[]{ true, false, false};     //?
                        break;
            default:    lum = null;
                        break;
        }
        return lum;
    }
    
    /**
     * minimum values pf color components
     * @param type
     * @return
     */
    public static int[] getMin(int type){
        int[] min;
        switch (type){
            case(RGB):  min = new int[]{ 0, 0, 0};
                        break;
            case(HSV):  min = new int[]{ 0, 0, 0};
                        break;
            case(Yxy):  min = new int[]{ 0, 0, 0};
                        break;
            case(Lab):  min = new int[]{ 0, -128, -128};
                        break;
            case(LCh):  min = new int[]{ 0, 0, 0};
                        break;
            case(Luv):  min = new int[]{ 0, -200, -200};     //?
                        break;
            default:    min = null;
                        break;
        }
        return min;
    }
    
    /**
     * maximum values of color components
     * @param type
     * @return
     */
    public static int[] getMax(int type){
        int[] max;
        switch (type){
            case(RGB):  max = new int[]{ 255, 255, 255};
                        break;
            case(HSV):  max = new int[]{ 360, 100, 100};
                        break;
            case(Yxy):  max = new int[]{ 100, 1, 1};
                        break;
            case(Lab):  max = new int[]{ 100, 127, 127};
                        break;
            case(LCh):  max = new int[]{ 100, 200, 360};     //?
                        break;
            case(Luv):  max = new int[]{ 100, 200, 200};     //?
                        break;
            default:    max = null;
                        break;
        }
        return max;
    }
    
    public static int[] getRange(int type){
        int[] min = getMin(type);
        int[] max = getMax(type);
        int[] range = new int[max.length]; 
        for (int i = 0; i < max.length; i++) {
            range[i] = max[i] - min[i];
        }
        return range;
    }
    
    public static String getName(int type){
        return SPACE_NAME[type];
    }
   
    public static String getCompName(int type, int index) {
        String[] compName;
        if (index < 0 || index > 2)
            return null;
        switch(type){
            case(RGB):  compName = new String[]{"R", "G", "B"};
                        break;
            case(HSV):  compName = new String[]{"Hue", "Saturation", "Value"};
                        break;
            case(Yxy):  compName = new String[]{"Y", "x", "y"};
                        break;
            case(Lab):  compName = new String[]{"L", "a", "b"};
                        break;
            case(LCh):  compName = new String[]{"L", "C", "h"};
                        break;
            case(Luv):  compName = new String[]{"L", "u", "v"};
                        break;
            default:    compName = new String[]{"Component 0", "Component 1", "Component 2"};
                        break;
        }
        return compName[index];
    }
}
